package com.spiro.bintest;

import java.nio.ByteBuffer;
import java.util.Arrays;

import org.apache.thrift.TException;

import com.spiro.bintest.BinTest.Iface;

public class BinTestHandler implements Iface {

    @Override
    public void put(ByteBuffer data) throws TException {
        
        byte[] dst = new byte[data.limit() - data.position()];
        data.get(dst);
        
        System.out.println("server put=>" + Arrays.toString(dst));
        
        return;
    }

    @Override
    public ByteBuffer get() throws TException {

        ByteBuffer bb = ByteBuffer.wrap(new byte[] { 122, 123 });
        System.out.println("server get=>" + Arrays.toString(bb.array())
                + ", pos=" + bb.position() + ", limit=" + bb.limit());
        return bb;
    }

}
